package com.lau.vo;

import lombok.Data;

import java.util.List;

/**
 * @author:Lau
 * @create: 2022-12-19 10:29
 * @Description: 封装分页参数
 */
@Data
public class PagingParams {
    /**
     * 分页大小
     */
    private int pageSize = 10;

    /**
     * 当前页数
     */
    private int pageIndex = 1;

    /**
     * 总记录数
     */
    private Long totalCount;

    /**
     * 排序字段信息
     */
    private List<SortField> sortFieldList;

    public long getTotalPage() {
        if (getTotalCount() == null || getTotalCount() < 1) {
            return 0;
        }
        return getTotalCount() / getPageSize() + (getTotalCount() % getPageSize() > 0 ? 1 : 0);
    }
}
